package com.cncsi.service;


import com.cncsi.dao.DepartmentRepository;
import com.cncsi.dao.ProjectRepositoty;
import com.cncsi.dao.UserRepository;
import com.cncsi.entity.Department;
import com.cncsi.entity.Project;
import com.cncsi.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;

/**
 * Created by liuyf90 on 2018/5/6.
 */
@Service
@Transactional
public class ProjectService {
    @Autowired
    private ProjectRepositoty projectRepositoty;
    @Autowired
    private UserRepository userRepository;
    @Autowired
    private DepartmentRepository departmentRepository;

    public List<Project> getProjectList(){
        List<Project> projectList = projectRepositoty.findAll();
        return projectList;
    }
    public List<User> getUserList(){
        List<User> userList = userRepository.findAll();
        return userList;
    }
    public List<Department> getDepartmentList(){
        List<Department> departmentList = departmentRepository.findAll();
        return departmentList;
    }
    public List<Project> getProjectAll(){
        List<Project> projectAll = projectRepositoty.findAll();
        return projectAll;
    }

    public String saveProject(Project project) {


        try{
            projectRepositoty.save(project);
            return "成功";
        }catch(Exception e){
            System.out.println(e);
            return "失败";
        }
    }



}